﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DigitMatrix.Business
{
    public class MonitorFolder
    {
        public static int GetFreeDiskSpaceMB(string drive)
        {
            DriveInfo driveInfo = new DriveInfo(drive);
            long FreeSpace = driveInfo.AvailableFreeSpace;

            FreeSpace /= 1024 * 1024;
            return (int)FreeSpace;
        }

        private string _fileDirect = string.Empty;
        private int _saveDay = 0;

        public MonitorFolder(string fileDirect, int saveDay)
        {
            this._fileDirect = fileDirect;
            this._saveDay = saveDay;
        }
               

        private DateTime GetFolderDateTimeInfo(string folderName)
        {
            if (!CheckFolderNameIsNumber(folderName))
                return new DateTime();
            int year = Convert.ToInt32(folderName.Substring(0, 4));
            int month = Convert.ToInt32(folderName.Substring(4, 2));
            int day = Convert.ToInt32(folderName.Substring(6, 2));
            return new DateTime(year, month, day, 0, 0, 0);
        }

        private bool CheckFolderNameIsNumber(string folderName)
        {
            try
            {
                int temp = Convert.ToInt32(folderName);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
    }
}
